package com.company.clientscard.main.widgets.clientform;

import java.util.Date;

import com.google.gwt.i18n.client.DateTimeFormat;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.datepicker.client.CalendarUtil;
import com.google.gwt.user.datepicker.client.DateBox;

public class DatePick extends HorizontalPanel {
	final Label l1 = new Label("From");
	final DateBox date1 = new DateBox();
	final Label l2 = new Label("to");
	final DateBox date2 = new DateBox();

	DateTimeFormat fmt = DateTimeFormat.getFormat("dd.MM.yyyy");

	public DatePick() {
		Date firstDate = new Date();
		CalendarUtil.setToFirstDayOfMonth(firstDate);

		date1.setFormat(new DateBox.DefaultFormat(fmt));
		date1.setValue(firstDate);
		date1.setSize("80px", "14px");
		date2.setFormat(new DateBox.DefaultFormat(fmt));
		date2.setValue(new Date());
		date2.setSize("80px", "14px");

		setVerticalAlignment(ALIGN_MIDDLE);
		setSpacing(2);

		add(l1);
		add(date1);
		add(l2);
		add(date2);
	}

	public String getDate1() {
		return fmt.format(date1.getValue());
	}

	public String getDate2() {
		return fmt.format(date2.getValue());
	}

}
